package com.sxj.corejava.code09_集合.List;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author 石小俊
 * @date 2025年02月19日
 */
public class Test03_与数组的转换 {

    public static void main(String[] args) {
//        toArray();
        toList();
    }

    public static void toArray() {
        ArrayList list = new ArrayList();
        list.add(1);
        list.add("admin");
        list.add("tom");
        list.add(3.14);
        System.out.println(list);

        // 将指定的集合转换成数组
        Object[] arr = list.toArray();
        System.out.println(Arrays.toString(arr));
    }

    public static void toList() {
        String[] arr = {"admin", "tom", "lucy", "lily"};
        System.out.println(Arrays.toString(arr));

        List<String> list = Arrays.asList(arr);
        System.out.println(list);

//        ArrayList arrayList = new ArrayList(list);
        ArrayList arrayList = new ArrayList(Arrays.asList(arr));
        System.out.println(arrayList);
    }


}
